<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>还款验证码</title>
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<script src="../static/js/common.js?v=1"></script>
		<link rel="stylesheet" href="../static/css/common/reset.min.css" />
		<link rel="stylesheet" href="../static/css/common/mui.min.css" />
		<link rel="stylesheet" href="../static/css/user/bank_card_code.css?v=1" />

		<body>
			<ul>
				<li>
					<span>还款金额</span>
					<span id="repayMoney"></span>
				</li>

				<li>
					<span>手机号验证码</span>
					<span><input placeholder="请输入验证码" type="text" id="validateCode" /></span>
				</li>
			</ul>
			<div class="bind-card">
				<input type="button" value="确认还款" onclick="repay_active()" />
			</div>
			<div id="myModal" style="display:none">
				<img src="../static/img/loading.png">
			</div>
			<script src="../static/js/common/jquery.min.js"></script>
			<script src="../static/js/common/mui.min.js"></script>
			<script src="../static/js/bridge.js"></script>
			<script>
				var api_url = apiDomain();
				var token = getToken();

				function repay_active() {
					var validateCode = $("#validateCode").val();
					if(!validateCode) {
						mui.alert("请输入手机验证码");
						return
					}
					$.ajax({
						url: api_url + "order/repay_active",
						type: "post",
						dataType: "json",
						data: {
							token: token,
							repayNo: request['repayNo'],
							validateCode: validateCode
						},
						beforeSend: function() {
							$('#myModal').show();
						},
						success: function(data) {
							if(data.status == 2000) {
								var ua = navigator.userAgent.toLowerCase();
								if(/android/.test(ua)) {
									skipPage(1, webDomain() + "order/pay_return.html?orderId=" + data.data);
								} else {
									window.location.href = "pay_return.html?orderId=" + data.data;
								};
							} else {
								mui.alert(data.message);
							}
						},
						complete: function() {
							$('#myModal').stop().hide();
						}
					});
				}
				$.ajax({
					url: api_url + "order/repay_info",
					type: "post",
					dataType: "json",
					data: {
						token: token,
						repayNo: request['repayNo']
					},
					success: function(data) {
						if(data.status == 2000) {
							$("#repayMoney").text(data.data.shouldRepay + '元');
						}
					}
				});
			</script>
		</body>

</html>